package org.zhuxian.cn.common;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum EquipmentSlot {
    Weapon("武器", 0),
    UpperBody("上身", 1),
    Head("头部", 2),
    Hand("手部", 3),
    Waist("腰部", 4),
    Foot("脚部", 5),
    Charm("护符", 6),
    Seal("法印", 8),
    Token("令牌", 9),
    ;

    public final String name;
    public final Integer type;

    EquipmentSlot(String name, Integer type) {
        this.name = name;
        this.type = type;
    }

    // 用于根据 name 属性快速查找枚举常量的映射
    private static final Map<String, EquipmentSlot> NAME_MAP = new HashMap<>();

    static {
        // 初始化映射
        for (EquipmentSlot slot : values()) {
            NAME_MAP.put(slot.name, slot);
        }
    }

    // 根据 name 属性查找枚举常量的方法
    public static EquipmentSlot fromName(String name) {
        return NAME_MAP.get(name);
    }
}
